import * as actionTypes from "./constants";
import { Map } from "immutable";

const defaultState = Map({
  categories: [],
  currentId: 0,
  fine: [],
  radios: {},
  currentPage: 1
});

const reducer = (state = defaultState, action) => {
  switch (action.type) {
    case actionTypes.CHANGE_RADIO_CATEGORY:
      return state.set("categories", action.categories);
    case actionTypes.CHANGE_RADIO_CURRENTID:
      return state.set("currentId", action.id);
    case actionTypes.CHANGE_RADIO_FINE:
      return state.set("fine", action.fine);
    case actionTypes.CHANGE_RADIO_RANKING:
      return state.set("radios", action.djRadios);
    case actionTypes.CHANGE_RANKING_PAGE:
      return state.set("currentPage", action.page);
    default:
      return state;
  }
};

export default reducer;